package com.chen.q3;

import com.chen.q3.initial.NettyHttpServer;

/**
 * 整合CloseableHttpAsyncClient
 * @author Charles
 */
public class NettyServerApplication {
    final static String GATEWAY_NAME = "NIO_Gateway";
    final static String VERSION = "v2.0.0 Filter功能实现";

    public static void main(String[] args) {
        int proxyPort = 8088;
        String proxiedServer = "http://127.0.0.1:8801";

        if (args !=null ){
            if (args.length > 0){
                try {
                    proxyPort = Integer.valueOf(args[0]);
                } catch (NumberFormatException e) {
                    //端口号默认8088
                }
            }
            if (args.length > 1){
                proxiedServer = args[1];
            }
        }
        NettyHttpServer server = new NettyHttpServer(proxyPort,proxiedServer);
        try {
            System.out.println(GATEWAY_NAME + " " + VERSION + " start..." );
            server.run();
            System.out.println(GATEWAY_NAME + " " + VERSION + " started at http://localhost:"+ proxyPort + " for server:" + server.toString() );
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
